//
//  TiDanDetailHeadView.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2020/9/11.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "TiDanDetailHeadView.h"

@interface TiDanDetailHeadView ()

@property (nonatomic, strong) UILabel *companyLab;
@property (nonatomic, strong) UILabel *NOTitleLab;
@property (nonatomic, strong) UILabel *NOLab;
@property (nonatomic, strong) UIButton *phoneBtn;

@end

@implementation TiDanDetailHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = HexColor(0xffffff);
        self.companyLab = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, ScreenW - 30 - 30 - 15, 19)];
        self.companyLab.font = BoldFontOfSize(18);
        self.companyLab.textColor = HexColor(0x2B2C44);
        [self addSubview:self.companyLab];
        
        self.phoneBtn = [UIButton new];
        self.phoneBtn.nim_width = 30;
        self.phoneBtn.nim_height = 30;
        self.phoneBtn.nim_left = ScreenW - 15 - 30;
        self.phoneBtn.nim_centerY = self.companyLab.nim_centerY;
        [self.phoneBtn setImage:[UIImage imageNamed:@"icon_phone_click"] forState:0];
        [self.phoneBtn addTarget:self action:@selector(phoneClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.phoneBtn];
        
        self.NOTitleLab = [UILabel new];
        self.NOTitleLab.font = [UIFont systemFontOfSize:14];
        self.NOTitleLab.textColor = HexColor(0x9C9DB3);
        self.NOTitleLab.text = @"调度时间：";
        [self.NOTitleLab sizeToFit];
        self.NOTitleLab.nim_left = self.companyLab.nim_left;
        self.NOTitleLab.nim_top = self.companyLab.nim_bottom + 10;
        [self addSubview:self.NOTitleLab];
        
        self.NOLab = [[UILabel alloc] initWithFrame:CGRectMake(self.NOTitleLab.nim_right, self.NOTitleLab.nim_top, ScreenW - 15 - self.NOTitleLab.nim_right, self.NOTitleLab.nim_height)];
        self.NOLab.textColor = HexColor(0x2B2C44);
        self.NOLab.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.NOLab];
    }
    return self;
}

- (void)phoneClick {
    NSString *str = [[NSMutableString alloc] initWithFormat:@"tel:%@",self.model.info.tlogistics_mobile];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
}

-(void)setModel:(TiDanDetailModel *)model {
    _model = model;
    self.companyLab.text = model.info.tlogistics_name;
    self.NOLab.text = model.info.createTime;
}

@end
